<?php
namespace PsiFramework\Classes\Util\Object;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * The EMail class represents an e-mail
 *
 * @package Util.Object
 */
class EMail
{

    protected /*string*/ $_to ;
    protected /*string*/ $_subject ;
    protected /*string*/ $_message ;
    protected /*string*/ $_from ;

    /**
     * Constructor
     *
     * @param     string    $to            the to adress
     * @param     string    $subject    the subject
     * @param     string    $message    the message
     * @param     string    $from        the from address
     * @return    EMail    instance
     */
    public function __construct(
        /*string*/ $from,
        /*string*/ $to,
        /*string*/ $subject,
        /*string*/ $message
    )
    {
        $this->_from = $from ;
        $this->_to = $to ;
        $this->_subject = $subject ;
        $this->_message = $message ;
    }

    /**
     * Sends the message
     */
    public function send()
    {
        $headers = 'From: ' . $this->_from . "\r\n" .
                   'Reply-To: ' . $this->_from . "\r\n" .
                   'X-Mailer: PHP/' . phpversion() . "\r\n" .
                   'Content-Type: text/html; charset=UTF-8' ;

        @mail($this->_to, $this->_subject, $this->_message, $headers);
    }
}
